package com.lg.concurrent.atomic;

import java.util.concurrent.atomic.DoubleAccumulator;
import java.util.function.DoubleBinaryOperator;

public class DoubleAccumulatorTest {
    public static void main(String[] args) {
        DoubleBinaryOperator doubleBinaryOperator = (a, b) -> {
            return a * b;
        };
        // 创建一个 DoubleAccumulator 并设置初始值
        DoubleAccumulator doubleAccumulator = new DoubleAccumulator(doubleBinaryOperator,2f);

        // 根据 上面提供的 operator 运算，这里也就是  doubleBinaryOperator提供的值=2*3 变为6
        doubleAccumulator.accumulate(3);
        // 返回 doubleAccumlator 提供的值
        System.out.println( doubleAccumulator.get());

    }
}
